Skip to content

Conversation

@jsignell
Copy link
Member

@jsignell jsignell commented Nov 19, 2024

Related Issue(s):

Description:

>>> import pystac
>>> 
>>> collection = pystac.Collection.from_file("./tests/data-files/catalogs/cbers-partial/CBERS4MUX/collection.json")
>>> collection.item_assets
{'thumbnail': <pystac.item_assets.ItemAssetDefinition at 0x72aea0420750>,
 'metadata': <pystac.item_assets.ItemAssetDefinition at 0x72aea017dc90>,
 'B5': <pystac.item_assets.ItemAssetDefinition at 0x72aea017efd0>,
 'B6': <pystac.item_assets.ItemAssetDefinition at 0x72aea016d5d0>,
 'B7': <pystac.item_assets.ItemAssetDefinition at 0x72aea016e050>,
 'B8': <pystac.item_assets.ItemAssetDefinition at 0x72aea016da90>}
>>> collection.item_assets["thumbnail"].title
'Thumbnail'
>>> collection.item_assets["thumbnail"].title = "fake"
>>> collection.item_assets["thumbnail"].title
'fake'
>>> collection.item_assets["B4"] = {
    'type': 'image/tiff; application=geotiff; profile=cloud-optimized',
    'eo:bands': [{'name': 'B4', 'common_name': 'red'}]
}
>>>collection.item_assets["B4"].owner == collection
True

Notes:
This approach is a little wonky, but it is a backwards compatible change. Shown here (a688988) passing with no test changes.

TODO:

  • Add deprecation warning when accessing the ItemAssetsExtension class. I think the simplest approach will be to warn when instantiating that class.
  • Add tests/docs demonstrating new access patterns.

PR Checklist:

  • Pre-commit hooks and tests pass (run scripts/test)
  • Documentation has been updated to reflect changes, if applicable
  • This PR maintains or improves overall codebase code coverage.
  • Changes are added to the CHANGELOG. See the docs for information about adding to the changelog.

@codecov
Copy link

codecov bot commented Nov 19, 2024

Codecov Report

Attention: Patch coverage is 94.59459% with 10 lines in your changes missing coverage. Please review.

Project coverage is 91.31%. Comparing base (f15e3f6) to head (38e6662).
Report is 37 commits behind head on main.

Files with missing lines Patch % Lines
pystac/collection.py 84.61% 1 Missing and 1 partial ⚠️
pystac/extensions/datacube.py 75.00% 0 Missing and 1 partial ⚠️
pystac/extensions/pointcloud.py 80.00% 0 Missing and 1 partial ⚠️
pystac/extensions/projection.py 80.00% 0 Missing and 1 partial ⚠️
pystac/extensions/sar.py 80.00% 0 Missing and 1 partial ⚠️
pystac/extensions/sat.py 80.00% 0 Missing and 1 partial ⚠️
pystac/extensions/storage.py 80.00% 0 Missing and 1 partial ⚠️
pystac/extensions/table.py 75.00% 0 Missing and 1 partial ⚠️
pystac/extensions/view.py 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1476      +/-   ##
==========================================
+ Coverage   91.17%   91.31%   +0.13%     
==========================================
  Files          52       53       +1     
  Lines        7253     7286      +33     
  Branches      877      883       +6     
==========================================
+ Hits         6613     6653      +40     
+ Misses        460      453       -7     
  Partials      180      180              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jsignell jsignell marked this pull request as ready for review January 3, 2025 21:23
@gadomski gadomski self-requested a review January 3, 2025 21:43
@jsignell jsignell added this pull request to the merge queue Jan 6, 2025
Merged via the queue into stac-utils:main with commit 43cfdec Jan 6, 2025
23 checks passed
@jsignell jsignell deleted the item-assets branch January 6, 2025 15:07
kmodali pushed a commit to kmodali/pystac that referenced this pull request Oct 16, 2025
* Move item_assets out of extensions

* Move item_assets to dummy file

* Move item_assets out of dummy file

* Add new `item_assets` access pattern

* Export AssetDefinition

* Add deprecated warning and update tests

* Remove schema uri from stac_extensions on migrate

* Update docs

* Add some more tests

* Remove TYPE_CHECKING

* Update changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate item_assets extension and move into collection core

2 participants